test :- p(X), writeln(X), fail ; true.

%-----------------------------------------------------------------------

:- table p/1.

p(X) :- t(X,Y,Z), tnot(p(Y)), tnot(p(Z)).
p(b).

t(a,b,a).
t(a,a,b).
